package cn.le.crawler.gpw;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

public class GPWPropertyUtil {

    //地区
    private static final Map<String,Integer> AREA_MAP;
    static {
        AREA_MAP = new HashMap<String, Integer>() {{
            put("北京",11);put("重庆",50);put("河北",5);put("山西",14);put("辽宁",21);
            put("上海",31);put("吉林",22);put("黑龙江",23);put("内蒙古",15);put("江苏",32);
            put("天津",12);put("山东",37);put("安徽",34);put("浙江",33);put("福建",35);
            put("湖北",42);put("广东",44);put("广西",45);put("江西",36);put("四川",51);
            put("海南",46);put("贵州",52);put("云南",53);put("西藏",54);put("陕西",61);
            put("甘肃",62);put("青海",63);put("宁夏",64);put("新疆",65);put("河南",41);
            put("湖南",43);
        }};
    }

    private static final String URL = "http://s.gpai.net/sf/search.do?at=376&cityNum=";
    private static final int PAGE_SUM = 6;


    static List<String> getUrls(){
        List<String> urls = new LinkedList<>();
        AREA_MAP.forEach((key,val)->{
            for (int i = 1; i <= PAGE_SUM; i++) {
                StringBuilder builder = new StringBuilder()
                        .append(URL).append(val).append("&?Page=").append(i);
                urls.add(builder.toString());
            }
        });
        return urls;
    }

}
